function res_ll = compute_pd_LL(I,res_wc)
% Compute log-linearized solution for the wealth-consumption ratio

% Set Options
options_fmincon = optimoptions('fmincon','Algorithm','sqp', 'MaxFunEvals', 100000,'MaxIter',200,'Display','iter','FinDiffType','central');

% Solve system of equations for mean wealth-consumption ratio
mean_pd_init = 6.5;
[mean_pd,~,Exitflag] = fmincon(@(x) 1,mean_pd_init,[],[],[],[],[],[],@(x) wrap_vec(mean_pd_LL(x,I,res_wc)),options_fmincon);

if Exitflag == 1
else
    error('Log-Linearization did not converge')
end

% Compute linearization parameters 
[~, res_ll.kappad_0, res_ll.kappad_1, res_ll.Ad_0, res_ll.Ad_1 , res_ll.Ad_2] = mean_pd_LL(mean_pd,I,res_wc);

end